package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by Administrater on 2015/12/8.
 */
public class TiXianTask extends CouponHttpBaseTask {
    private String mMoney;
    private String mAliNo;
    private  String mTrueName;
    private int type;

    public TiXianTask(String money,String alipayNo,String trueName,int type){
        super(TaskType.TIXIAN_TASK);
        mMoney = money;
        mAliNo = alipayNo;
        mTrueName = trueName;
        this.type = type;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.TIXIAN_REQUEST);
            JSONObject json = new JSONObject();
            json.put("money", mMoney);
            json.put("alipayNo",mAliNo);
            json.put("trueName",mTrueName);
            json.put("type",type);
            request.setData(json.toString());
            request.setApiNo(ApiNo.TIXIAN);
            addRequest(request);
        }
    }
}
